<template>
  <div class="header-box" @dblclick="handleMaximizeWindow">
    <img alt="logo" class="logo" src="@renderer/assets/image/logo.svg" />
    <div class="header-center">
      <span class="sub-title">通用仪表参数配置工具</span>
      <small>(V1.0.0)</small>
    </div>
    <div class="header-right flex align-center">
      <!-- <el-dropdown placement="bottom" @command="setLocale">
        <svg data-v-f414ea64="" viewBox="0 0 24 24" width="1.2em" height="1.2em" class="lang-title">
          <path
            fill="currentColor"
            d="m18.5 10l4.4 11h-2.155l-1.201-3h-4.09l-1.199 3h-2.154L16.5 10h2zM10 2v2h6v2h-1.968a18.222 18.222 0 0 1-3.62 6.301a14.864 14.864 0 0 0 2.336 1.707l-.751 1.878A17.015 17.015 0 0 1 9 13.725a16.676 16.676 0 0 1-6.201 3.548l-.536-1.929a14.7 14.7 0 0 0 5.327-3.042A18.078 18.078 0 0 1 4.767 8h2.24A16.032 16.032 0 0 0 9 10.877a16.165 16.165 0 0 0 2.91-4.876L2 6V4h6V2h2zm7.5 10.885L16.253 16h2.492L17.5 12.885z"
          ></path>
        </svg>
        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item command="zhCN">简体中文</el-dropdown-item>
            <el-dropdown-item command="en">English</el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown> -->

      <span class="option-btn option-close" @click="handleMinWindow">
        <el-icon><SemiSelect /></el-icon>
      </span>
      <!-- <span class="option-btn option-close" @click="handleMaxWindow">
        <el-icon><FullScreen /></el-icon>
      </span> -->
      <span class="option-btn" @click="closeWindow">
        <el-icon><CloseBold /></el-icon>
      </span>
    </div>
  </div>
</template>

<script lang='ts' setup>
import { useI18n } from 'vue-i18n'
const { locale, t } = useI18n()

// 关闭窗体
const closeWindow = () => window.electron.ipcRenderer.send('window-close')

// 最小化窗体
const handleMinWindow = () => window.electron.ipcRenderer.send('window-min')

// 最大化窗体
const handleMaxWindow = () => window.electron.ipcRenderer.send('window-max')

// 禁用双击最大化
const handleMaximizeWindow = () => window.electron.ipcRenderer.send('maximize-window')

// 切换语言
const setLocale = (lang) => {
  locale.value = lang;
  localStorage.setItem('language', lang) // 更新localStorage
}
</script>

<style lang='scss' scoped>
.header-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 10px;
  box-sizing: border-box;
  height: $default-header-height;
  line-height: $default-header-height;
  /* background: $default-bg-color; */
  border-radius: $boxRadius;
  -webkit-app-region: drag;

  .logo {
    -webkit-app-region: no-drag;
  }

  .header-center {
    -webkit-app-region: no-drag;
    .sub-title {
      font-size: 30px;
      margin-right: 7px;
      font-family: PangMenZhengDao;
      color: #fff;
    }
    .sup-title {
      font-size: 15px;
    }
  }

  .header-right {
    >>> .el-dropdown {
      .el-tooltip__trigger {
        outline: none;
        border: none;
      }
    }
    .lang-title {
      color: #fff;
      font-size: 13px;
      margin-right: 15px;
      -webkit-app-region: no-drag;
      cursor: pointer;
      outline: none;
    }

    .option-btn {
      width: 32px;
      height: 32px;
      border-radius: 1px;
      display: flex;
      justify-content: center;
      align-items: center;
      -webkit-app-region: no-drag;
      transition: background 0.3s ease;
      cursor: pointer;

      &:hover {
        background: #2a2d3e;
      }
    }

    .option-close {
      margin-right: 6px;
    }
  }
}
</style>